#ifndef MAINAPP_H
#define MAINAPP_H

#include <QMainWindow>
#include "Simulation.h"

/// @namespace Ui the Ui namespace created from the MainWindow class
namespace Ui
{
    class MainWindow;
}

/// @file MainApp.h
/// @brief represents the main gui application window, modified from JMacey's demo
/// @author Perseedoss Rajiv
/// @version 1.0
/// @date 04.06.11
/// Revision History :
/// Initial Version 04.06.11
/// @class MainApp
/// @brief contains all the UI extended from MainWindow.ui and our GLWindow

class MainApp : public QMainWindow
{
Q_OBJECT

public:
    /// @brief ctor
    /// @param[in] _parent the main application window for the GUI
    MainApp(
            QWidget* _parent = 0
            );

    /// @brief dtor
    ~MainApp();


private:
    /// @brief the handle to the main GUI window, used for creating all the UI and the gl window
    Ui::MainWindow* m_ui;

    /// @brief the main gl context that is used for drawing and creation of the simulation
    Simulation* m_simulation;

private:
    /// @brief setup up the UI intial values and connects signals/slots
    void setupConnections();

    /// @brief override the keyPressEvent inherited from QObject so we can handle key presses.
    /// @param [in] _event the event to process
    void keyPressEvent(
                       QKeyEvent* _event
                      );

    /// @brief updates the gui with the parameters of a newly selected sphere
    /// @param [in] _sphereId the sphere id selected
    void refreshControlsFromSphere(const int _sphereId);

    /// @brief updates the gui with the parameters of a newly selected capsule
    /// @param [in] _capsuleId the capsule id selected
    void refreshControlsFromCapsule(const int _capsuleId);

    /// @brief updates the gui with the parameters of a newly selected fluid
    /// @param [in] _fluidId the fluid id selected
    void refreshControlsFromFluid(const int _fluidId);


private slots:
    //GUI dynamic controls event here

    void on_cmd_injectParticle_clicked();
    void on_cmd_flushCache_clicked();
    void on_cmd_autoMove_clicked();
    void on_spin_fluid_interfaceColorPlus_clicked(bool checked);
    void on_spin_fluid_interfaceColorMinus_clicked(bool checked);
    void on_spin_fluid_interfaceThreshold_valueChanged(double );
    void on_spin_fluid_interfaceCoefficient_valueChanged(double );
    void on_spin_fluid_surfaceThreshold_valueChanged(double );
    void on_spin_fluid_surfaceCoefficient_valueChanged(double );
    void on_spin_fluid_viscosityConstant_valueChanged(double );
    void on_spin_fluid_gasConstant_valueChanged(double );
    void on_spin_fluid_restDensity_valueChanged(double );
    void on_cmb_fluid_currentFluid_currentIndexChanged(int index);
    void on_spin_solver_smoothingLength_valueChanged(double );
    void on_cmb_solver_integrationMethod_currentIndexChanged(int index);
    void on_spin_solver_timestep_valueChanged(double );
    void on_spin_environment_capsule_centre_z_valueChanged(double );
    void on_spin_environment_capsule_centre_y_valueChanged(double );
    void on_spin_environment_capsule_centre_x_valueChanged(double );
    void on_spin_environment_capsule_incrementAngle_valueChanged(int );
    void on_chk_environment_capsule_isStatic_clicked(bool checked);
    void on_spin_environment_capsule_radius_valueChanged(double );
    void on_chk_environment_sphere_isStatic_clicked(bool checked);
    void on_spin_environment_sphere_radius_valueChanged(double );
    void on_spin_environment_sphere_velocity_z_valueChanged(int );
    void on_spin_environment_sphere_velocity_y_valueChanged(int );
    void on_spin_environment_sphere_velocity_x_valueChanged(int );
    void on_spin_environment_sphere_centre_z_valueChanged(int );
    void on_spin_environment_sphere_centre_y_valueChanged(int );
    void on_spin_environment_sphere_centre_x_valueChanged(int );
    void on_cmb_environment_capsule_currentIndexChanged(int index);
    void on_cmb_environment_sphere_currentIndexChanged(int index);
    void on_spin_environment_boundary_size_z_valueChanged(int );
    void on_spin_environment_boundary_size_y_valueChanged(int );
    void on_spin_environment_boundary_size_x_valueChanged(int );
    void on_spin_environment_boundary_periodicWall_angleIncrement_valueChanged(int );
    void on_spin_environment_boundary_periodicWall_speed_valueChanged(double );
    void on_spin_environment_boundary_periodicWall_maxAmplitude_valueChanged(int );
    void on_chk_environment_boundary_enablePeriodicWall_clicked(bool checked);
    void on_spin_environment_boundary_restitutionForRBD_valueChanged(double );
    void on_spin_environment_boundary_restitutionForFluid_valueChanged(double );
    void on_checkBox_clicked(bool checked);
    void on_spin_environment_boundary_centre_z_valueChanged(int );
    void on_spin_environment_boundary_centre_y_valueChanged(int );
    void on_spin_environment_boundary_centre_x_valueChanged(int );
    void on_spin_environment_capsule_resolution_valueChanged(int );
    void on_spin_environment_rbd_restitution_valueChanged(double );
    void on_spin_hose_velocity_z_valueChanged(int );
    void on_spin_hose_velocity_y_valueChanged(int );
    void on_spin_hose_velocity_x_valueChanged(int );
    void on_spin_hose_centre_z_valueChanged(int );
    void on_spin_hose_centre_y_valueChanged(int );
    void on_spin_hose_centre_x_valueChanged(int );
    void on_chk_fluid_hose_waitUntilRBD_clicked(bool checked);
    void on_chk_fluid_hose_waitUntilBoundary_clicked(bool checked);
    void on_chk_fluid_hose_drawMarker_clicked(bool checked);
    void on_spin_cache_automaticFlushInterval_valueChanged(int );
    void on_chk_cache_automaticFlush_clicked(bool checked);
    void on_chk_cache_exportBoundary_clicked(bool checked);
    void on_chk_cache_exportRBD_clicked(bool checked);
    void on_spin_cache_samplingInterval_valueChanged(int );
    void on_chk_cache_enable_clicked(bool checked);

    void on_cmd_singleStep_clicked();

    void on_cmd_2DFrontView_clicked();

    void on_cmd_2DTopView_clicked();
};

#endif // MAINAPP_H
